<!doctype html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../assert_selection.js"></script>
<script>
test(() => assert_selection(
  [
    '<div contenteditable>',
      '^<table><tr><td>hello</td><td>world</td></tr></table>|',
    '</div>',
  ].join(''),
  'formatBlock P',
  [
    '<div contenteditable>',
      '<p>^<table><tbody><tr><td>hello</td><td>world</td></tr></tbody></table>|</p>',
    '</div>',
  ].join('')), '0 select all children with P');

test(() => assert_selection(
  [
    '<div contenteditable>',
      '<table><tr><td>^hello|</td><td>world</td></tr></table>',
    '</div>',
  ].join(''),
  'formatBlock P',
  [
    '<div contenteditable>',
      '<table><tbody><tr>',
        '<td><p>^hello|</p></td><td>world</td>',
      '</tr></tbody></table>',
    '</div>',
  ].join('')), '1 select first cell with BLOCKQUOTE');

test(() => assert_selection(
  [
    '<div contenteditable>',
      '<table><tr>',
        '<td>^<p>hello</p>|<div>world</div></td><td>Blink</td>',
      '</tr></table>',
    '</div>',
  ].join(''),
  'formatBlock BLOCKQUOTE',
  [
    '<div contenteditable>',
      '<table><tbody><tr>',
        '<td><blockquote>^hello|</blockquote><div>world</div></td><td>Blink</td>',
      '</tr></tbody></table>',
    '</div>',
  ].join('')), '2 select first cell with BLOCKQUOTE');

test(() => assert_selection(
  [
    '<div contenteditable>',
      '<table><tr>',
        '<td>^<ul><li>hello</li><li>world</li></ul>|</td><td>Blink</td>',
      '</tr></table>',
    '</div>',
  ].join(''),
  'formatBlock ADDRESS',
  [
    '<div contenteditable>',
      '<table><tbody><tr>',
        '<td><address>',
          '<ul><li>^hello</li></ul><ul><li>world|</li></ul>',
        '</address></td>',
        '<td>Blink</td>',
      '</tr></tbody></table>',
    '</div>',
  ].join('')), '3 select first cell with ADDRESS');
</script>
